#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>

main()
{
    struct rlimit rl;
    int i,pid;

    i = getrlimit(RLIMIT_CPU,&rl);

    printf("%d: max CPU time (in seconds) is %d\n",getpid(),rl.rlim_max);

    pid = fork();

    if (pid != 0)
    {
        i = wait(0);
	printf("child terminated\n");
    }
    else
    {
	rl.rlim_cur = 5;
	rl.rlim_max = 5;
	i = setrlimit(RLIMIT_CPU,&rl);
        i = getrlimit(RLIMIT_CPU,&rl);
	printf("%d: max CPU time (in seconds) is %d\n",getpid(),rl.rlim_max);
	for (;;)
	    ;
    }
}
